package com.hhf.cloud.controller;

import com.hhf.cloud.config.DynamicThreadPool;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Daniel-黄海峰
 * @Description
 * @create 2024/3/8 21:19
 */
@RestController
public class ThreadPoolController {

    @Resource
    private DynamicThreadPool dynamicThreadPool;


    /**
     * 打印当前线程池的状态
     */
    @GetMapping(value = "/threadpool/print")
    public String printThreadPoolStatus() {
        return dynamicThreadPool.printThreadPoolStatus();
    }

    /**
     * 给线程池增加任务
     *
     * @param count
     */
    @GetMapping(value = "/threadpool/add/{count}")
    public String dynamicThreadPoolAddTask(@PathVariable("count") int count)
    {
        dynamicThreadPool.dynamicThreadPoolAddTask(count);
        return String.valueOf(count);
    }
}
